package com.zcx.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author zhaochangxin
 * @date 2022/3/2 16:29
 * 返回接口
 * code 0未成功 -1为失败
 */
@Data
@AllArgsConstructor
public class ApiResult<T> {
    // 状态码
    private Integer code;
    // 返回信息
    private String message;
    // 数据计数
    private Long count;
    // 返回数据
    private T Data;

    public static ApiResult<Object> success()
    {
        return new ApiResult(0,"success",null,null);
    }
    public static ApiResult<Object> success(String message)
    {
        return new ApiResult(0,message,null,null);
    }
    public static ApiResult<Object> success(String message,Object data)
    {
        return new ApiResult(0,message,null,data);
    }
    public static ApiResult<Object> success(String message,Object data,long limit) {
        return new ApiResult(0,message,limit,data);
    }
    public static ApiResult<Object> fail()
    {
        return new ApiResult(-1,"fail",null,null);
    }
    public static ApiResult<Object> fail(String message)
    {
        return new ApiResult(-1,message,null,null);
    }

}
